<template>
  <!-- 组件中应用的常用组件  -->
  <!-- 跳转页面组件 -->
  <view @click="goPage()" style="height: 100%">
    <slot></slot>
  </view>
</template>

<script>
const app = getApp();

import { pageUrls } from "../div-base/div-page-urls.js";
import util from "@/utils/util";

export default {
  props: {
    pageUrl: {
      type: String,
      default: "",
    },
  },
  components: {},
  watch: {
    pageUrl() {},
  },
  data() {
    return {
      pageUrls: pageUrls,
    };
  },
  methods: {
    goPage() {
      if (this.pageUrl) {
        let i = this.pageUrl.indexOf("?webUrl");
        if (i != -1) {
          let url = this.pageUrl;
          url = url.substring(0, url.indexOf("?")) + "?webUrl=" + encodeURIComponent(url.substring(url.indexOf("?webUrl=") + 8));
          uni.navigateTo({
            url,
          });
          return;
        }

        if (this.pageUrls.tabPages.indexOf(this.pageUrl) != -1) {
          uni.switchTab({
            url: this.pageUrl,
          });
        } else {
          uni.navigateTo({
            url: this.pageUrl,
          });
        }
      }
    },
  },
};
</script>

<style scoped lang="scss"></style>
